

#include "tools/socket.h"
#include "tools/dump.h"
#include "tools/file_util.h"
#include "tools/string_util.h"
#include "http.h"
#include "file_scripter.h"
#include "sp_scripter.h"
#include <string>
#include <fstream>
#include <sstream>
#include <map>
#include <list>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "log.h"


int main()
{
    logging::DecorateDefaultLogTracer();

    tools::CSocket  sockA(tools::CSocket::eSocketType_TCP);
    tools::CSocket::InitNetwork();
    tools::CSocket  sockL(tools::CSocket::eSocketType_TCP);

    FileScripter    fs;
    SpScripter      sp;

    try {
        sockL.Create();
        sockL.Bind(10008);
        sockL.Listen();

        while (true) {
            sockL.Accept(sockA);
            Http    http(&sockA);
            http.RegisterDefaultScripter(&fs);
            http.Register("sp", &sp);
            http.Register("so", &sp);
            while (true) {
                char    buffer[4096];
                int ret = sockA.Recv(buffer, sizeof(buffer));
                if (ret <= 0)
                    break;
                http.Read(buffer, ret);
            }
            sockA.Close();
        }
    } catch (const char * e) {
        PRINTF("error: %s\n", e);
    }

    return 0;
}















